package com.example.ai.controller;

import com.example.ai.dto.question.QuestionRequest;
import com.example.ai.dto.question.QuestionResponse;
import com.example.ai.service.ChatService;
import com.example.ai.service.QuestionService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/questions")
@RequiredArgsConstructor
@CrossOrigin(origins = "*", maxAge = 3600)
public class QuestionController {

    private final QuestionService questionService;
    private final ChatService chatService;
    @PostMapping
    public QuestionResponse askQuestion(@Valid @RequestBody QuestionRequest request) {
        return chatService.askQuestion(request);
    }

    @GetMapping
    public ResponseEntity<Page<QuestionResponse>> getUserQuestions(Pageable pageable) {
        return ResponseEntity.ok(questionService.getUserQuestions(pageable));
    }
} 